import { expect } from 'chai';
import { convertToUpperCase, isNotEmpty } from '../src/util';

describe('util', () => {
  describe('convertToUpperCase', () => {
    it('should convert lowercase string to uppercase', () => {
      const result = convertToUpperCase('hello world');
      expect(result).to.equal('HELLO WORLD');
    });

    it('should convert mixed case string to uppercase', () => {
      const result = convertToUpperCase('HeLLo WoRLd');
      expect(result).to.equal('HELLO WORLD');
    });

    it('should handle empty string', () => {
      const result = convertToUpperCase('');
      expect(result).to.equal('');
    });

    it('should handle string with numbers and special characters', () => {
      const result = convertToUpperCase('test123!@#$');
      expect(result).to.equal('TEST123!@#$');
    });

    it('should handle single character', () => {
      const result = convertToUpperCase('a');
      expect(result).to.equal('A');
    });

    it('should handle Chinese characters', () => {
      const result = convertToUpperCase('测试');
      expect(result).to.equal('测试');
    });
  });

  describe('isNotEmpty', () => {
    describe('null and undefined', () => {
      it('should return false for null', () => {
        expect(isNotEmpty(null)).to.be.false;
      });

      it('should return false for undefined', () => {
        expect(isNotEmpty(undefined)).to.be.false;
      });
    });

    describe('boolean values', () => {
      it('should return false for false', () => {
        expect(isNotEmpty(false)).to.be.false;
      });

      it('should return true for true', () => {
        expect(isNotEmpty(true)).to.be.true;
      });
    });

    describe('string values', () => {
      it('should return false for empty string', () => {
        expect(isNotEmpty('')).to.be.false;
      });

      it('should return false for string with only spaces', () => {
        expect(isNotEmpty('   ')).to.be.false;
      });

      it('should return false for string with tabs and newlines', () => {
        expect(isNotEmpty('\t\n\r')).to.be.false;
      });

      it('should return true for non-empty string', () => {
        expect(isNotEmpty('hello')).to.be.true;
      });

      it('should return true for string with spaces between characters', () => {
        expect(isNotEmpty(' h e l l o ')).to.be.true;
      });

      it('should return true for zero as string', () => {
        expect(isNotEmpty('0')).to.be.true;
      });
    });

    describe('array values', () => {
      it('should return false for empty array', () => {
        expect(isNotEmpty([])).to.be.false;
      });

      it('should return true for non-empty array', () => {
        expect(isNotEmpty([1, 2, 3])).to.be.true;
      });

      it('should return true for array with empty string', () => {
        expect(isNotEmpty([''])).to.be.true;
      });
    });

    describe('Map values', () => {
      it('should return false for empty Map', () => {
        expect(isNotEmpty(new Map())).to.be.false;
      });

      it('should return true for non-empty Map', () => {
        const map = new Map();
        map.set('key', 'value');
        expect(isNotEmpty(map)).to.be.true;
      });
    });

    describe('number values', () => {
      it('should return true for zero', () => {
        expect(isNotEmpty(0)).to.be.true;
      });

      it('should return true for positive numbers', () => {
        expect(isNotEmpty(123)).to.be.true;
      });

      it('should return true for negative numbers', () => {
        expect(isNotEmpty(-123)).to.be.true;
      });

      it('should return true for floating point numbers', () => {
        expect(isNotEmpty(3.14)).to.be.true;
      });
    });

    describe('object values', () => {
      it('should return true for empty object', () => {
        expect(isNotEmpty({})).to.be.true;
      });

      it('should return true for non-empty object', () => {
        expect(isNotEmpty({ key: 'value' })).to.be.true;
      });

      it('should return true for object with null prototype', () => {
        const obj = Object.create(null);
        obj.key = 'value';
        expect(isNotEmpty(obj)).to.be.true;
      });
    });

    describe('function values', () => {
      it('should return true for function', () => {
        expect(isNotEmpty(() => {})).to.be.true;
      });

      it('should return true for arrow function', () => {
        expect(isNotEmpty(() => 'test')).to.be.true;
      });
    });

    describe('complex scenarios', () => {
      it('should handle nested empty structures', () => {
        const nested = { arr: [], str: '   ', map: new Map() };
        expect(isNotEmpty(nested)).to.be.true;
      });

      it('should handle Date objects', () => {
        expect(isNotEmpty(new Date())).to.be.true;
      });

      it('should handle RegExp objects', () => {
        expect(isNotEmpty(/test/)).to.be.true;
      });

      it('should handle Symbol values', () => {
        expect(isNotEmpty(Symbol('test'))).to.be.true;
      });
    });
  });
});